package cn.class2.demo6

import scala.util.Random

/**
  * Created by lzd on 2018/11/14.
  * 不通类型数组单个值匹配
  */
object Demo2 {
  def main(args: Array[String]): Unit = {
    val arr = Array("scala", 123, 2.0, Demo2)
    val value: Any = arr(Random.nextInt(arr.length))
    println(s"最后结果值$value")
    value match {
      case x: Int => {
        println(s"选中的值$x")
      }
      case y: String => {
        println(s"选中的值$y")
      }
      case Demo2 => {
        val res = Demo2.hashCode()
        println(res)
      }
      case _ => println("default")
    }
  }
}
